package com.wxlgroup.springboot.controller;
import cn.hutool.core.util.StrUtil;
import com.wxlgroup.springboot.commons.Response;
import com.wxlgroup.springboot.entity.UserDto;
import com.wxlgroup.springboot.service.LoginService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
 * @auther:wxl
 * @Date:2022/5/23-05-23-15:38
 * @Description:com.wxlgroup.springboot.controller
 * @Version:1.0
 */
@RestController
@RequestMapping("/user")
public class LoginController {

    @Resource
    private LoginService loginService;

    @PostMapping("/login")
    public Response login(@RequestBody UserDto userDto){
        String username = userDto.getUsername();
        String password = userDto.getPassword();
        if(StrUtil.isBlank(username) || StrUtil.isBlank(password)){
            return new Response("500",null,"账号或密码不能为空");
        }
        return loginService.login(userDto);
    }
}
